package yk.com.AllMenu;

import java.util.Scanner;

public class Menu {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 进入主菜单
        boolean exit = false;
        while (!exit) {
            // 显示主菜单
            displayMenu();
            System.out.print("请输入您的选择: ");
            int choice = scanner.nextInt();
            scanner.nextLine(); // 清除输入缓冲区

            // 根据用户选择执行操作
            switch (choice) {
                case 1:
                    AddStudent.execute(scanner);
                    break;
                case 2:
                    RemoveStudent.execute(scanner);
                    break;
                case 3:
                    ModifyStudent.execute(scanner);
                    break;
                case 4:
                    QueryStudent.execute(scanner);
                    break;
                case 5:
                    System.out.println("正在退出系统...");
                    exit = true;
                    break;
                default:
                    System.out.println("无效的选择，请重新输入！");
                    break;
            }
        }

        scanner.close();
    }

    // 显示主菜单
    private static void displayMenu() {
        System.out.println("-----欢迎使用学生管理系统-----");
        System.out.println("1. 添加学生");
        System.out.println("2. 删除学生");
        System.out.println("3. 修改学生");
        System.out.println("4. 查询学生");
        System.out.println("5. 退出系统");
    }
}